#include<iostream>

using namespace std;

class Solution {
public:
	// 快乐数
    int bitSum(int n) { // 求一个数每位平方的和
        int sum = 0;
        while (n) {
            int x = n % 10;
            sum += x * x;
            n /= 10;
        }

        return sum;
    }

    bool isHappy(int n) {
        int fast = n, slow = n;
        do {
            slow = bitSum(slow);
            fast = bitSum(bitSum(fast));
        } while (fast != slow);

        return fast == 1;
    }
};

int main()
{

	return 0;
}
